{% extends 'base.html' %}
{% block content %}
{% if posts %}
    <ul>
    {% for post in posts %}
        <li><a href="/posts/{{ post.id }}">{{ post.position }}</a> || свободно мест: {{ post.free }} || стоят на посту: 
        {% for choice in post.userchoice_set.all %}
            {%if user == choice.user.username %}
                <text style="color:red;">{{ choice.user }},</text>
            {% else %}
                {{ choice.user }},
            {% endif %}
        {% endfor %}</li>
    {% endfor %}
    </ul>
{% else %}
    <p>No posts are available.</p>
{% endif %}
<form action="{% url 'home' %}" method="post">{% for post in posts %}
    <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ post.position }}" checked />
    <label for="choice{{ forloop.counter }}">{{ post.position }}</label><br />
{% endfor %}
<input type="submit" value="Подтвердить" />
{% csrf_token %}

</form>
{% endblock %}